package Information_sysyem_jdbc.Test;

import Information_sysyem_jdbc.Service.InformationService;
import Information_sysyem_jdbc.Service.impl.InformationServiceimpl;
import Information_sysyem_jdbc.entity.Information;
import org.junit.Test;
import java.util.List;
import java.util.Scanner;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.8.21 上午 10:13
 */
public class InformationDemoTest {
    Scanner sc = new Scanner(System.in);
    @Test
    public void testselectFindAll(){
        InformationService informationService = new InformationServiceimpl();
        List<Information> list = informationService.selectFindAllGet();
        if(list != null){
            for (Information information : list) {
                System.out.println(information);
            }
        }
    }

    @Test
    public void testSelectByid(){
       InformationService informationService = new InformationServiceimpl();
        Information information = informationService.selectfindByidGet(3);
        System.out.println(information);
    }

    @Test
    public void testSelectaccount(){
        InformationService informationService = new InformationServiceimpl();
        int countGet = informationService.selectAllCountGet();
        System.out.println("共有"+countGet+"条数据");
    }

    @Test
    public void testadd(){
        InformationService informationService = new InformationServiceimpl();
        Information information = new Information();
        information.setId(5);
        information.setName("汪一帆");
        information.setGender("男");
        information.setAge(20);
        information.setAddress("陕西省渭南市蒲城县");
        information.setPhone("19267564439");
        informationService.addGet(information);
    }

    @Test
    public  void testdelete(){
        InformationService informationService = new InformationServiceimpl();
        informationService.deleteGet(5);
    }

    @Test
    public void testupdate(){
        InformationService informationService = new InformationServiceimpl();
        System.out.println("请输入所要修改的id:");
        int i = informationService.updateInformationGet(sc.nextInt());
        if(i>0){
            System.out.println("该id号修改成功");
        }
    }



}
